<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>车辆信息登记</title>
    <!-- 引入WeUI CSS -->
    
  <link rel="stylesheet" href="./weui/weui.min.css">
    <style>
        /* 全局样式 */
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #e4efe9 100%);
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            min-height: 100vh;
            padding-bottom: 20px;
        }
        
        .page-container {
            max-width: 600px;
            margin: 0 auto;
            padding: 15px;
        }
        
        /* 头部样式优化 */
        .header {
            text-align: center;
            margin-bottom: 25px;
            padding: 25px 0 15px;
            position: relative;
        }
        
        .header::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 60px;
            height: 4px;
            background: linear-gradient(to right, #07C160, #10a5c5);
            border-radius: 2px;
        }
        
        .header-title {
            font-size: 26px;
            color: #333;
            font-weight: 600;
            margin-bottom: 10px;
            letter-spacing: 1px;
        }
        
        .header-desc {
            font-size: 15px;
            color: #666;
            line-height: 1.5;
        }
        
        /* 表单样式优化 */
        .weui-form {
            background-color: #fff;
            border-radius: 16px;
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
            overflow: hidden;
            padding: 0 15px;
            transition: transform 0.3s ease;
        }
        
        .weui-form:hover {
            transform: translateY(-3px);
        }
        
        .weui-cells {
            margin-top: 0;
        }
        
        .weui-cell {
            padding: 18px 0;
            transition: background-color 0.2s;
        }
        
        .weui-cell:active {
            background-color: rgba(7, 193, 96, 0.05);
        }
        
        .weui-label {
            font-size: 17px;
            color: #333;
            width: 80px;
            font-weight: 500;
        }
        
        .weui-input {
            font-size: 16px;
            color: #333;
            padding: 10px 0;
            transition: border-color 0.3s;
            border-bottom: 1px solid #e5e5e5;
        }
        
        .weui-input:focus {
            border-bottom: 2px solid #07C160;
            padding-bottom: 9px; /* 保持总高度不变 */
        }
        
        .input-container {
            display: flex;
            align-items: center;
            width: 100%;
        }
        
        .weui-cell__bd {
            flex: 1;
        }
        
        /* 图标样式优化 */
        .icon-container {
            display: flex;
            align-items: center;
            margin-left: 10px;
        }
        
        .valid-icon {
            color: #07C160;
            font-size: 18px;
            display: none;
        }
        
        .invalid-icon {
            color: #f43530;
            font-size: 18px;
            display: none;
        }
        
        /* 错误提示样式 */
        .weui-cells__tips {
            font-size: 14px;
            color: #f43530!important;
            margin-top: 6px;
            padding-left: 80px;
            display: none;
            animation: fadeIn 0.3s;
        }
        
        /* 提交按钮区域 */
        .weui-form__opr-area {
            margin: 35px 0 25px;
        }
        
        .weui-btn_primary {
            background: linear-gradient(to right, #07C160, #10a5c5);
            border-radius: 10px;
            height: 50px;
            /* line-height: 50px; */
            font-size: 18px;
            font-weight: 500;
            box-shadow: 0 4px 10px rgba(7, 193, 96, 0.3);
            transition: all 0.3s;
        }
        
        .weui-btn_primary:not(.weui-btn_disabled):active {
            transform: translateY(2px);
            box-shadow: 0 2px 5px rgba(7, 193, 96, 0.3);
        }
        
        .weui-btn_disabled {
            background: #E6E6E6;
            color: #999;
            box-shadow: none;
        }
        
        /* 动画效果 */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        
        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            15%, 45%, 75% { transform: translateX(-5px); }
            30%, 60%, 90% { transform: translateX(5px); }
        }
        
        .shake {
            animation: shake 0.6s;
        }
        
        /* 响应式调整 */
        @media (max-width: 375px) {
            .weui-label {
                width: 70px;
            }
            
            .weui-cells__tips {
                padding-left: 70px;
            }
            
            .header-title {
                font-size: 22px;
            }
        }
        
        /* 表单组间距 */
        .weui-cells__group {
            margin-bottom: 10px;
        }
        
        /* 输入框placeholder样式 */
        .weui-input::placeholder {
            color: #bbb;
            font-size: 15px;
        }
        
        /* 底部信息 */
        .footer {
            text-align: center;
            margin-top: 25px;
            font-size: 13px;
            color: #999;
        }
    </style>
</head>
<body>
    <div class="page-container">
        <div class="header">
            <h1 class="header-title">车辆信息登记</h1>
            <p class="header-desc">请填写真实信息完成车辆登记</p>
        </div>
        
        <div class="weui-form">
            <div class="weui-cells__group weui-cells__group_form">
                <!-- 姓名输入 -->
                <div class="weui-cells weui-cells_form">
                    <div class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd">
                            <label class="weui-label">姓名</label>
                        </div>
                        <div class="weui-cell__bd">
                            <div class="input-container">
                                <input class="weui-input" id="name" type="text" placeholder="请输入您的真实姓名">
                                <div class="icon-container">
                                    <span class="valid-icon" id="nameValid">✓</span>
                                    <span class="invalid-icon" id="nameInvalid">✗</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="weui-cells__tips" id="nameError">请输入2-10个中文字符</div>
                
                <!-- 手机号输入 -->
                <div class="weui-cells weui-cells_form">
                    <div class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd">
                            <label class="weui-label">手机号</label>
                        </div>
                        <div class="weui-cell__bd">
                            <div class="input-container">
                                <input class="weui-input" id="phone" type="tel" placeholder="请输入11位手机号" maxlength="11">
                                <div class="icon-container">
                                    <span class="valid-icon" id="phoneValid">✓</span>
                                    <span class="invalid-icon" id="phoneInvalid">✗</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="weui-cells__tips" id="phoneError">请输入有效的11位手机号</div>
                
                <!-- 车牌号输入 -->
                <div class="weui-cells weui-cells_form">
                    <div class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd">
                            <label class="weui-label">车牌号</label>
                        </div>
                        <div class="weui-cell__bd">
                            <div class="input-container">
                                <input class="weui-input" id="plate" type="text" placeholder="例如：京A12345">
                                <div class="icon-container">
                                    <span class="valid-icon" id="plateValid">✓</span>
                                    <span class="invalid-icon" id="plateInvalid">✗</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="weui-cells__tips" id="plateError">请输入有效的车牌号</div>
            </div>
            
            <div class="weui-form__opr-area">
                <button type="button" class="weui-btn weui-btn_primary" id="submitBtn" >提交登记</button>
            </div>
        </div>
        
       
    </div>

    <!-- 引入WeUI JS -->
  <script src="./weui/axios.min.js"></script>
<script  src="./weui/weui.min.js"></script>
  <script src="./axios.js"></script>
    
    <script>
        // 获取DOM元素
        const nameInput = document.getElementById('name');
        const phoneInput = document.getElementById('phone');
        const plateInput = document.getElementById('plate');
        const submitBtn = document.getElementById('submitBtn');
        
        // 验证状态
        let isNameValid = false;
        let isPhoneValid = false;
        let isPlateValid = false;
        
        // 初始化隐藏所有错误提示和图标
        document.querySelectorAll('.weui-cells__tips').forEach(el => el.style.display = 'none');
        document.querySelectorAll('.valid-icon, .invalid-icon').forEach(el => el.style.display = 'none');
        
        // 姓名验证（2-10个中文字符）
        function validateName(name) {
            return /^[\u4e00-\u9fa5]{2,10}$/.test(name);
        }
        
        // 手机号验证（11位数字，1开头）
        function validatePhone(phone) {
            return /^1[3-9]\d{9}$/.test(phone);
        }
        
        // 车牌号验证（简单验证）
        function validatePlate(plate) {
            return /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4,5}[A-Z0-9挂学警港澳]{1}$/.test(plate);
        }
        
        // 更新提交按钮状态
        function updateSubmitButton() {
            submitBtn.disabled = !(isNameValid && isPhoneValid && isPlateValid);
        }
        
        // 显示验证结果
        function showValidationResult(input, isValid, validIcon, invalidIcon, errorMsg, shouldShake = false) {
            if (input.value.trim().length > 0) {
                if (isValid) {
                    validIcon.style.display = 'inline';
                    invalidIcon.style.display = 'none';
                    errorMsg.style.display = 'none';
                } else {
                    validIcon.style.display = 'none';
                    invalidIcon.style.display = 'inline';
                    errorMsg.style.display = 'block';
                    
                    // 只在需要时添加抖动效果
                    if (shouldShake) {
                        input.parentElement.parentElement.classList.add('shake');
                        setTimeout(() => {
                            input.parentElement.parentElement.classList.remove('shake');
                        }, 600);
                    }
                }
            } else {
                validIcon.style.display = 'none';
                invalidIcon.style.display = 'none';
                errorMsg.style.display = 'none';
            }
            
            updateSubmitButton();
        }
        
        // 姓名输入验证（输入时只显示图标，不抖动）
        nameInput.addEventListener('input', function() {
            const name = this.value.trim();
            isNameValid = validateName(name);
            
            showValidationResult(
                this, 
                isNameValid, 
                document.getElementById('nameValid'),
                document.getElementById('nameInvalid'),
                document.getElementById('nameError'),
                false // 不触发抖动
            );
        });
        
        // 姓名失焦验证（失焦时触发抖动）
        nameInput.addEventListener('blur', function() {
            const name = this.value.trim();
            isNameValid = validateName(name);
            
            showValidationResult(
                this, 
                isNameValid, 
                document.getElementById('nameValid'),
                document.getElementById('nameInvalid'),
                document.getElementById('nameError'),
                !isNameValid && name.length > 0 // 有内容但无效时抖动
            );
        });
        
        // 手机号输入验证（输入时只显示图标，不抖动）
        phoneInput.addEventListener('input', function() {
            const phone = this.value.trim();
            isPhoneValid = validatePhone(phone);
            
            showValidationResult(
                this, 
                isPhoneValid, 
                document.getElementById('phoneValid'),
                document.getElementById('phoneInvalid'),
                document.getElementById('phoneError'),
                false // 不触发抖动
            );
        });
        
        // 手机号失焦验证（失焦时触发抖动）
        phoneInput.addEventListener('blur', function() {
            const phone = this.value.trim();
            isPhoneValid = validatePhone(phone);
            
            showValidationResult(
                this, 
                isPhoneValid, 
                document.getElementById('phoneValid'),
                document.getElementById('phoneInvalid'),
                document.getElementById('phoneError'),
                !isPhoneValid && phone.length > 0 // 有内容但无效时抖动
            );
        });
        
        // 车牌号输入验证（输入时只显示图标，不抖动）
        plateInput.addEventListener('input', function() {
            const plate = this.value.trim();
            isPlateValid = validatePlate(plate);
            
            showValidationResult(
                this, 
                isPlateValid, 
                document.getElementById('plateValid'),
                document.getElementById('plateInvalid'),
                document.getElementById('plateError'),
                false // 不触发抖动
            );
        });
        
        // 车牌号失焦验证（失焦时触发抖动）
        plateInput.addEventListener('blur', function() {
            const plate = this.value.trim();
            isPlateValid = validatePlate(plate);
            
            showValidationResult(
                this, 
                isPlateValid, 
                document.getElementById('plateValid'),
                document.getElementById('plateInvalid'),
                document.getElementById('plateError'),
                !isPlateValid && plate.length > 0 // 有内容但无效时抖动
            );
        });
        
        // 提交按钮点击事件
     // 提交按钮点击事件
submitBtn.addEventListener('click', function() {
    // 获取输入值
    const name = nameInput.value.trim();
    const phone = phoneInput.value.trim();
    const plate = plateInput.value.trim();
    
    // 验证所有字段
    isNameValid = validateName(name);
    isPhoneValid = validatePhone(phone);
    isPlateValid = validatePlate(plate);
    
    // 重置所有错误提示和图标
    document.querySelectorAll('.weui-cells__tips').forEach(el => el.style.display = 'none');
    document.querySelectorAll('.valid-icon, .invalid-icon').forEach(el => el.style.display = 'none');
    document.querySelectorAll('.shake').forEach(el => el.classList.remove('shake'));
    
    // 检查并显示所有字段的错误状态
    let hasError = false;
    
    // 姓名验证
    if (name.length === 0) {
        document.getElementById('nameError').textContent = "请输入姓名";
        document.getElementById('nameError').style.display = 'block';
        document.getElementById('nameInvalid').style.display = 'inline';
        nameInput.parentElement.parentElement.classList.add('shake');
        hasError = true;
    } else if (!isNameValid) {
        document.getElementById('nameError').textContent = "请输入2-10个中文字符";
        document.getElementById('nameError').style.display = 'block';
        document.getElementById('nameInvalid').style.display = 'inline';
        nameInput.parentElement.parentElement.classList.add('shake');
        hasError = true;
    } else {
        document.getElementById('nameValid').style.display = 'inline';
    }
    
    // 手机号验证
    if (phone.length === 0) {
        document.getElementById('phoneError').textContent = "请输入手机号";
        document.getElementById('phoneError').style.display = 'block';
        document.getElementById('phoneInvalid').style.display = 'inline';
        phoneInput.parentElement.parentElement.classList.add('shake');
        hasError = true;
    } else if (!isPhoneValid) {
        document.getElementById('phoneError').textContent = "请输入有效的11位手机号";
        document.getElementById('phoneError').style.display = 'block';
        document.getElementById('phoneInvalid').style.display = 'inline';
        phoneInput.parentElement.parentElement.classList.add('shake');
        hasError = true;
    } else {
        document.getElementById('phoneValid').style.display = 'inline';
    }
    
    // 车牌号验证
    if (plate.length === 0) {
        document.getElementById('plateError').textContent = "请输入车牌号";
        document.getElementById('plateError').style.display = 'block';
        document.getElementById('plateInvalid').style.display = 'inline';
        plateInput.parentElement.parentElement.classList.add('shake');
        hasError = true;
    } else if (!isPlateValid) {
        document.getElementById('plateError').textContent = "请输入有效的车牌号";
        document.getElementById('plateError').style.display = 'block';
        document.getElementById('plateInvalid').style.display = 'inline';
        plateInput.parentElement.parentElement.classList.add('shake');
        hasError = true;
    } else {
        document.getElementById('plateValid').style.display = 'inline';
    }
    
    // 如果有错误，滚动到第一个错误的位置
    if (hasError) {
        const firstErrorElement = document.querySelector('.weui-cells__tips[style="display: block;"]');
        if (firstErrorElement) {
            firstErrorElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
        }
        
        // 移除抖动效果
        setTimeout(() => {
            document.querySelectorAll('.shake').forEach(el => {
                el.classList.remove('shake');
            });
        }, 600);
        
        return;
    }
    
    // 所有验证通过，提交表单
    // 显示加载中
    const loading = weui.loading('提交中...');
    
    // 模拟提交延迟
    setTimeout(() => {
        loading.hide();
        
        // 显示成功提示
        weui.toast('登记成功', {
            className: 'weui-toast_success',
            duration: 2000
        });
        
        // 这里可以添加实际的提交逻辑
        console.log('提交数据:', { name, phone, plate });
        
        // 3秒后重置表单
        setTimeout(() => {
            nameInput.value = '';
            phoneInput.value = '';
            plateInput.value = '';
            isNameValid = isPhoneValid = isPlateValid = false;
            updateSubmitButton();
            document.querySelectorAll('.valid-icon, .invalid-icon').forEach(el => el.style.display = 'none');
            document.querySelectorAll('.weui-cells__tips').forEach(el => el.style.display = 'none');
        }, 2000);
    }, 1500);
});
    </script>
</body>
</html>